#include <iostream>
#include <fstream>

#include "state.hpp"
#include "conversion.hpp"

using namespace std;

char *paste(int);
char *paste(const char *, int, int, int);
bool compare(State *);

int main(int argc, char** argv)
{
    int init, rank, size;
    MPI_Initialized(&init);
    if (!init)
        MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);

    bool OK;
    for (int n = 3; n <= 23; n += 5) {
        //State state1(n), state2(n), state4(n), state8(n);
        State state[4];
        ifstream in;

        for (int i = 1, j = 0; i < 9; i *= 2, j++) {
            res = paste(dir, n, 1, i);
            in.open(res);
            in >> state[j];
            in.close();
        }
        OK = compare(state);

        for (int i = 1, j = 0; i < 9; i *= 2, j++) {
            res = paste(dir, n, n/2 + 1, i);
            in.open(res);
            in >> state[j];
            in.close();
        }
        OK = compare(state);

        for (int i = 1, j = 0; i < 9; i *= 2, j++) {
            res = paste(dir, n, 1, i);
            in.open(res);
            in >> state[j];
            in.close();
        }
        OK = compare(state);

    }
    return 0;
}
